<%@ page language="java" import="java.util.*,java.lang.*,live.common.*"
	pageEncoding="UTF-8"%>
<%@page import="live.jipiao.entity.AirOrder"%>
<%@page import="live.pay.SignUtil"%>
<%@page import="live.pay.ServiceIds"%>
<%@page import="live.jipiao.dao.OrderPay"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/core.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<jsp:include page="../pub_head.jsp">
	<jsp:param value="3" name="type" />
</jsp:include>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
AirOrder order =  (AirOrder) request.getSession().getAttribute("order");
//一卡通支付
String userId=(String)session.getAttribute("ssoclientagent.user");
String req_trans_tm=Format.getInstance().dateFormatString(new Date(), "yyyyMMddHHmmss");
String req_trans_seq=GetSequence.getInstance().returnSeqNum();
String subject_desc = OrderPay.returnFlightSubject(order);
Map map = new TreeMap();
map.put("service_id",ServiceIds.PRE_AUTH_RES);
map.put("req_org_cd",PostParam.FLIGHT_NAME);
map.put("req_trans_tm",req_trans_tm);
map.put("req_trans_seq",req_trans_seq);
map.put("order_id",order.getOrderNo());
map.put("seller_id",PostParam.FLIGHT_NAME);
map.put("sub_order_flag","N");
map.put("sub_order_num","0");
map.put("order_desc",subject_desc);
map.put("tot_trans_amt",((int)(Double.parseDouble(order.getOrderTotal().toString())*100))+"");
map.put("buyer_id",userId);
map.put("valid_date","0");
map.put("notify_url",PostParam.FLIGHT_NOTIFY);
map.put("return_url","");
String sign=SignUtil.sign(map,PostParam.PAYKEY);
map.put("sign",sign);
map.put("sign_type","MD5");
if(order.getOrderStatus().toString().trim().equals("0")){
request.getSession().setAttribute("map",map);
}
//支付宝支付
	//	String paygateway = "https://www.alipay.com/cooperate/gateway.do?"; //支付接口（不可以修改）
	//	String service = "create_direct_pay_by_user";//快速付款交易服务（不可以修改）
	//	String sign_type = "MD5";//文件加密机制（不可以修改）
	//	String out_trade_no = order.getOrderNo().toString();//商户网站订单（也就是外部订单号，是通过客户网站传给支付宝，不可以重复）
	//	String input_charset = "utf-8";  //（不可以修改）
		//partner和key提取方法：登陆签约支付宝账户--->点击“商家服务”就可以看到
	//	String partner = AlipayConfig.partnerID; //支付宝合作伙伴id (账户内提取)
	//	String key = AlipayConfig.key; //支付宝安全校验码(账户内提取)
	//	String body = new OrderPay().returnFlightBody(order); //商品描述，推荐格式：商品名称（订单编号：订单编号）
	//	String total_fee = order.getOrderTotal()+""; //订单总价
	//	String payment_type = "1";//支付宝类型.1代表商品购买（目前填写1即可，不可以修改）
	//	String seller_email =  AlipayConfig.sellerEmail; //卖家支付宝帐户,例如：gwl25@126.com
	//	String subject = subject_desc + out_trade_no; //商品名称
	//	String show_url = "http://localhost:8080";  //根据集成的网站而定 例如：http://wow.alipay.com
		
	//	String path_yu = request.getScheme() + "://" + request.getServerName()
	//			+ ":" + request.getServerPort();// "http://190.10.2.33:7001/"; 

	//	String notify_url = path_yu + ""; //通知接收URL(本地测试时，服务器返回无法测试)
	//	String return_url = path_yu + ""; //支付完成后跳转返回的网址URL
	    //注意以上两个地址 要用 http://格式的完整路径
	    /*以下两个参数paymethod和defaultbank可以选择不使用，如果不使用需要注销，并在Payment类的方法中也要注销*/
	//	String paymethod = request.getParameter("paymethod").trim();//赋值:bankPay(网银);cartoon(卡通); directPay(余额)
	//	String defaultbank = request.getParameter("defaultbank").trim();
		//ICBCB2C	中国工商银行
		//CMB		招商银行
		//CCB		中国建设银行
		//ABC		中国农业银行
		//SPDB		上海浦东发展银行
		//SPDBB2B	上海浦东发展银行(B2B)
		//CIB	兴业银行
		//GDB		广东发展银行
		//SDB	深圳发展银行
		//CMBC		中国民生银行
		//COMM		交通银行
		//POSTGC		邮政储蓄银行
		//CITIC		中信银行
		//CCBVISA	建行VISA
		//VISA		VISA
	    
	//	String ItemUrl = Payment.CreateUrl(paygateway, service, sign_type,
	//			out_trade_no, input_charset, partner, key, show_url, body,
	//			total_fee, payment_type, seller_email, subject, notify_url,
	//			return_url);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<META content="text/html; charset=UTF-8" http-equiv="Content-Type">
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

		<title>订单提交成功</title>

		<link href="css/orderforms.css" type="text/css" rel="stylesheet"
			media="all" />
		<link href="css/submitOK.css" type="text/css" rel="stylesheet"
			media="all" />
		<script type="text/javascript" src="script/zDrag.js"></script>
		<script type="text/javascript" src="script/zDialog.js"></script>
		<script type="text/javascript" src="script/jquery.cluetip.js"></script>

		<style>
</style>
	</head>
	<body>
		<!--Header Begin-->

		<link href="css/global.css" type="text/css" rel="stylesheet"
			media="all" />
		<!--Header include start-->
		<SCRIPT type="text/javascript"> 
var login_Ishide = true;
var login_FFvar = 0;
var shID = "loginbg";
function showdiv() {
    if (!login_Ishide) return;
    var sh_login = document.getElementById(shID);
    sh_login.style.display = "block";
    if (navigator.userAgent.indexOf("MSIE") > 0) {
        if (sh_login.filters.alpha.opacity >= 70) {
            clearTimeout(login_Timer);
            sh_login.filters.alpha.opacity = 70;
            login_Ishide = false;
			login_HideTimer = setTimeout("hidediv()", 5000);
            return;
        } else {
            sh_login.filters.alpha.opacity += 1;
            login_Timer = setTimeout("showdiv()", 50);
            return;
        }
    } else {
        if (sh_login.style.opacity >= 0.7) {
            clearTimeout(login_Timer);
            sh_login.style.opacity = 0.7;
            login_Ishide = false;
			login_HideTimer = setTimeout("hidediv()", 5000);
            return;
        } else {
            login_FFvar += 0.01;
            sh_login.style.opacity = login_FFvar;
            login_Timer = setTimeout("showdiv()", 50);
            return;
        }
    }
}
function hidediv() {
    if (login_Ishide) return;
    var sh_login = document.getElementById(shID);
    login_Timer = null;
    if (navigator.userAgent.indexOf("MSIE") > 0) {
        if (sh_login.filters.alpha.opacity <= 5) {
            sh_login.style.display = "none";
            login_Timer = null;
            login_Ishide = true;
            return;
        }
        sh_login.filters.alpha.opacity = sh_login.filters.alpha.opacity - 1;
        if (sh_login.filters.alpha.opacity <= 0) sh_login.filters.alpha.opacity = 0;
        login_Timer = setTimeout("hidediv() ", 10);
    } else {
        if (sh_login.style.opacity <= 0.01) {
            sh_login.style.display = "none";
            login_Timer = null;
            login_Ishide = true;
            login_FFvar = 0;
            return;
        }
        login_FFvar -= 0.01;
        sh_login.style.opacity = login_FFvar;
        if (sh_login.style.opacity <= 0) sh_login.style.opacity = 0;
        login_Timer = setTimeout("hidediv() ", 10);
    }
}
</SCRIPT>
		<c:if test="${order==null}">
			<script type="text/javascript">
<!--
	location.href='error/404.jsp';
//-->
</script>
		</c:if>
		<!-- top 专题小头部 start -->
		<!-- top 专题小头部 end -->
		<!--Header include end-->
		<!--Header End-->
		<!--OrderConent Begin-->
		<div class="wrapper clearfix">
			<div class="stepout fillingt">
				<h1>
					订单提交成功
				</h1>
				<ul>
					<li class="current">
						选择
					</li>
					<li class="current">
						下单
					</li>
					<li class="current">
						核对
					</li>
					<li class="current">
						完成
					</li>
				</ul>
			</div>
			<!--订单信息-->
			<div class="submitOK-sub">
				<div class="scon s ">
					<h6>
						恭喜您，订单提交成功
					</h6>
					<div class="t ut">
						<h2>
							订单号：${order.orderNo}
						</h2>
					</div>
					<div class="gotocit checkorder">
						<div class="t ut" onClick="DownDiv('uTDiv','uT')">
							<h2>
								订单机票信息,请认真核对后进行支付
							</h2>
							<b id="uTDiv" class="up">+</b>
						</div>
						<div class="gotocit flaghtorder" style="display: block;" id="uT">
							<table class="borderb ">
								<tr>
									<td>
										<strong style="display: none">去程</strong>
									</td>
									<td>
										<img src="flight/airpic/${order.aircom}.gif" width="16"
											height="16" />
										深航
										<br />
										${order.flightNo}
									</td>
									<td>
										<p>
											${order.scity }起飞：
											<bean:write name="order" property="depTime"
												format="yy/MM/dd HH:mm" />
										</p>
										<p>
											到达${order.ecity }：
											<bean:write name="order" property="arrTime"
												format="yy/MM/dd HH:mm" />
										</p>
									</td>
									<td>
										<p>
											成人：票价(&yen;${order.fare})+机建费(&yen;${order.cost})=&yen;${order.fare+order.cost}（含税）
										</p>
									</td>
									<td>
										<p>
											<logic:iterate id="passenger" name="order"
												property="passengerList">
												<SPAN class=name>&nbsp;&nbsp;${passenger.username }</SPAN>
											</logic:iterate>
										</p>
									</td>
								</tr>
							</table>

						</div>
					</div>
					<div class="scon-oper">
						<div class="opertoporder">
							<H3>
								订单处理
							</H3>
							<div class="ordercon">
								<table border="0" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td>
											<img src="images/ordericonOK.gif" width="17" height="16" />
										</td>
										<td>
											<hr />
										</td>
										<td>
											<span class="oper tdw">&nbsp;</span>
											<img src="images/ordericoning.gif" width="17" height="16" />
										</td>
									</tr>
									<tr>
										<td>
											订单提交成功
										</td>
										<td>
											&nbsp;
										</td>
										<td class="oper tdw">
										<%if(order.getOrderStatus().toString().trim().equals("0")){ %>
											&nbsp;&nbsp;在线支付
										<%}if(order.getOrderStatus().toString().trim().equals("-3")){ %>
											等待订位
										<%} %>
										</td>
									</tr>
								</table>
							</div>
						</div>
	
						<ul class="operbut">
							<li>
							<%if(order.getOrderStatus().toString().trim().equals("0")){ %>
								非常歉意的告知您，由于系统已经为您保留座位，
								<span>请您在30分钟之内完成支付，过期您的订单将被取消。</span>&nbsp;&nbsp;&nbsp;&nbsp;
								<%}if(order.getOrderStatus().toString().trim().equals("-3")){ %>
								非常歉意的告知您，由于当前系统预订繁忙，稍候系统将自动为您预订座位，<br/>
								<span>预订成功后将以短信的形式通知您，收到短信后，请到用户中心进行机票支付操作！</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;
								<%} %>
								<a href="flight/order.do?op=getOrder&oid=${order.orderNo }"
									target="_blank">查看订单详情</a>
							</li>

							<li class="center fees">
								支付订单费用：
								<span>¥${order.orderTotal }</span>
								<%if(order.getOrderStatus().equals("0")){ %><b class="paybtn"
									onclick="javascript:startpay();return false;"></b><%} %>
							</li>
							<li>
								<br />
								当支付成功后出现如下情况，我们会及时为您退款并不收取任何费用。
								<br />
								因以下极端情况（权利由航空公司保留），可能导致订单未能生效，我们会第一时间与您联系：
								<br />
								·出票时票价上涨或下调
								<br />
								·座位不足或售空
								<br />
								·因不可抗力因素（如地震灾难等）导致航班取消或变更
							</li>
						</ul>
					</div>
					<div class="checkorder checktwo">
						<ul>
							后续处理 -> 出票
						</ul>
						<p>
							当您支付成功之后，我们将再次与航空公司确认您的座位，并在60分钟之内以手机短信或电话方式告知您。由于航空公司有权取消未出票的预订，如果处理过程中发生任何问题，我们会再次与您联系确认！
						</p>
						<ul>
							后续处理 -> 报销凭证
						</ul>
						<p>
							您选择了：
							<b>&#19981;&#38656;&#35201;&#25253;&#38144;&#20973;&#35777;</b>，请乘机人带好预订时所填写的证件到机场直接办理登机手续。
						</p>
					</div>
				</div>
			</div>
			<!--客服信息-->
			<div class="submitOK-sub">
				<div class="scon">
					<p class="fwb center thank">
						我们为您提供7天*24小时专业服务
					</p>
				</div>
			</div>
		</div>
		<!--OrderConent end-->
		<!--Help Begin-->

		<!--Help End-->
		<!--Footer Begin-->
		<!--Footer Start-->
		<!--Footer End-->
		<!--Footer End-->
		<script type="text/javascript" src="script/jquery.orders.js"></script>
		<div id="conver"></div>
		<div id="loading" style="display:none; border: solid 10px #247FB6;background-color: #FFFFFF; text-align: center;" align="center">
	<div style="height: 90px; border: text-align: left; font-family: '宋体'; font-size: 14px;"  align="left" >
		<span style="float: left;margin: 10px">
			<img src="/images/bg-sys-icon-info.gif" />
		</span>
	<p style="line-height: 18px">如果您关闭这个页面，意味着您放弃此次预订，订单将自动取消。如果您需要预订该航班，请您在倒计时结束前完成支付</p>
	<p>&nbsp;</p>
	<p>付款完成前请不要关闭此窗口</p>
	</div>
	<p style="vertical-align: bottom; position: relative; margin-top: 10px;">
    <button onclick="javascript:return torecon();" style="height:40px; padding:5px; font-size: 14px;font-weight:'bolder'; border:solid; " id="recon">已完成支付</button>
    <!-- <button style="height:40px; border:solid; margin-left:30px; padding:5px; cursor:pointer; font-weight:bolder; font-size: 14px; background-color: #247FB6; color: white;">已完成支付</button> -->
    </p>
</div>
<script type="text/javascript">
<!--
  	var secs = 9;
	var wait = secs * 1000;  	
	function popDiv(){
	var windowWidth = document.documentElement.offsetWidth;
	var windowHeight = document.documentElement.offsetHeight;
	$('#loading').css({
                    background: '#fff',
                    zIndex: 3000,
                    padding: '10px',
                    width: '600px',
                    height: '140px',
                    margin: '0 auto',
                    opacity: 1,
                    position: 'absolute',
                    top: windowHeight/2-134,
                    left: windowWidth/2-290
                  });
   	  $('#recon').css({ background: 'none',color:'gray'}).text('已完成支付 ('+secs+')').attr('disabled',true);
	    for(i = 1; i <= secs; i++)
         {window.setTimeout("upTime(" + i + ")", i * 1000);}
      $('#conver').css({
         	height:document.body.scrollHeight,
         	width:document.body.scrollWidth,
         	position: 'absolute',
         	margin:'0',
         	padding:'0',
         	left:'0px',
         	top:'0px',
         	opacity: '0.6',
         	zIndex: 2000,
         	background: '#ccc'
         });
     $('#loading').show();
     }
     
     function upTime(num){
     	if(num<secs)
     	{$('#recon').text('已完成支付 ('+((wait/1000)-num)+')');}
     	else{
     		$('#recon').css({background:'#247FB6',color: 'white',cursor:'pointer'}).attr('disabled',false);
     		$('#recon').text('已完成支付');
     	}
     }
    function torecon(){
    	$('form').first().attr('action','/recon.do').attr('target','_parent').submit();
    }
//-->
</script>
<%if(order.getOrderStatus().equals("0")){
	Date bookDate = Format.getInstance().stringToDate(order.getBookDate().toString(), "yyyy-MM-dd HH:mm");
	%>
		<input type="hidden" id="minites" value="<%=bookDate.getTime()/1000 %>" />
		<input id="second" type="hidden" value="1" />
		<input type="hidden" id="dd" value="<%=(bookDate.getTime()+30*1000)/1000 %>" />
		<form name="pform" action="<%=PostParam.PAY_API%>" method="post"
			target="_blank">
			<input type="hidden" name="service_id" value="<%=ServiceIds.PRE_AUTH_RES%>" />
			<input type="hidden" name="req_org_cd" value="<%=PostParam.FLIGHT_NAME %>" />
			<input type="hidden" name="req_trans_tm" value="<%=req_trans_tm%>" />
			<input type="hidden" name="req_trans_seq" value="<%=req_trans_seq%>" />
			<input type="hidden" name="order_id" value="${order.orderNo}" />
			<input type="hidden" name="seller_id" value="<%=PostParam.FLIGHT_NAME %>" />
			<input type="hidden" name="sub_order_flag" value="N" />
			<input type="hidden" name="sub_order_num" value="0" />
			<input type="hidden" name="order_desc" value="<%=subject_desc %>" />
			<input type="hidden" name="tot_trans_amt" value="<%=map.get("tot_trans_amt")%>" />
			<input type="hidden" name="buyer_id" value="<%=userId %>" />
			<input type="hidden" name="valid_date" value="0" />
			<input type="hidden" name="notify_url" value="<%=PostParam.FLIGHT_NOTIFY%>" />
			<input type="hidden" name="sign" value="<%=sign%>" />
			<input type="hidden" name="sign_type" value="MD5" />
		</form>
		<script type="text/javascript" defer="defer"> 

function startpay(){
popDiv();
var tt=$("#second").val();
if(tt==1){
$.ajax({
  url: "/flight/order.do?op=resquestAndResponse",
  cache: false,
  success: function(data){
   if(parseInt(data)==1){
	popDiv();
	$("#second").val(2);
	$(".paybtn").addClass("paybtned");
	$(".paybtned").unbind("click");
	document.forms['pform'].submit();
	}
  }
}); 
}
}
function recon(){
var oriSerId=$("input[name='service_id']").val();
var orderId=$("input[name='order_id']").val();
var seqNum=$("input[name='req_trans_seq']").val();
location.href='/recon.do?service_id='+oriSerId+'&order_id='+orderId+'&original_trans_seq='+seqNum+'&type=flight';
}
</script>
		<script> 
  	var  ssst=$("#minites").val();
  	var  ddd=$("#dd").val();
 
	var t=30*60-(parseInt(ddd)-parseInt(ssst));
  function setTime(){
	t--;
	$(".paybtn").html("剩余时间：<em>"+parseInt(t/60)+"</em>分钟");
	if(parseInt(t/60)==0){
	$(".paybtn").addClass("paybtned");
	$(".paybtned").unbind("click");
	$(".paybtned").attr("disabled","disabled");
	window.close();
	}
	if($("#second").val()==1){
	setTimeout("setTime()",1000);
	}
  }
	setTime();
</script><%} %>
<%@include file="../footer.jsp"%>
	</body>
</html>

